package com.winai.launcher.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.clj.fastble.data.BleDevice;

/**
 * 作者：康少
 * 时间：2019/11/19 0019
 * 说明：蓝牙设备
 */
public class BluetoothItemBean implements Parcelable {
    private int bluetoothId;
    private String bluetoothName;
    private BluetoothState mBluetoothState;
    private BleDevice device;

    /**
     * 说明：
     */
    public enum BluetoothState {
        UNLINK, LINKING, LINKED, UNBOND, BONDING, BONDED, SWITCH,
    }

    public BluetoothItemBean(int bluetoothId, String bluetoothName, BluetoothState mBluetoothState, BleDevice device) {
        this.bluetoothId = bluetoothId;
        this.bluetoothName = bluetoothName;
        this.mBluetoothState = mBluetoothState;
        this.device = device;
    }

    public int getBluetoothId() {
        return bluetoothId;
    }

    public void setBluetoothId(int bluetoothId) {
        this.bluetoothId = bluetoothId;
    }

    public String getBluetoothName() {
        return bluetoothName;
    }

    public void setBluetoothName(String bluetoothName) {
        this.bluetoothName = bluetoothName;
    }

    public BluetoothState getBluetoothState() {
        return mBluetoothState;
    }

    public void setBluetoothState(BluetoothState mBluetoothState) {
        this.mBluetoothState = mBluetoothState;
    }

    public BleDevice getDevice() {
        return device;
    }

    public void setDevice(BleDevice device) {
        this.device = device;
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.bluetoothId);
        dest.writeString(this.bluetoothName);
        dest.writeInt(this.mBluetoothState == null ? -1 : this.mBluetoothState.ordinal());
        dest.writeParcelable(this.device, flags);
    }

    protected BluetoothItemBean(Parcel in) {
        this.bluetoothId = in.readInt();
        this.bluetoothName = in.readString();
        int tmpMBluetoothState = in.readInt();
        this.mBluetoothState = tmpMBluetoothState == -1 ? null : BluetoothState.values()[tmpMBluetoothState];
        this.device = in.readParcelable(BleDevice.class.getClassLoader());
    }

    public static final Creator<BluetoothItemBean> CREATOR = new Creator<BluetoothItemBean>() {
        @Override
        public BluetoothItemBean createFromParcel(Parcel source) {
            return new BluetoothItemBean(source);
        }

        @Override
        public BluetoothItemBean[] newArray(int size) {
            return new BluetoothItemBean[size];
        }
    };
}
